<template>
  <el-container>
    <!-- 顶栏 -->
    <el-header height="120px">
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <el-date-picker
        type="date"
        value-format="yyyy-MM-dd"
        placeholder="请选择日期"
        v-model="startTime"
        style="width:200px;"
      ></el-date-picker>至
      <el-date-picker
        type="date"
        value-format="yyyy-MM-dd"
        placeholder="请选择日期"
        v-model="endTime"
        style="width:200px;"
      ></el-date-picker>
      收支类型:
      <el-select v-model="state" placeholder="请选择" style="width:200px">
        <el-option v-for="bean in stateList" :label="bean.name" :key="bean.id" :value="bean.id"></el-option>
      </el-select>
      <el-button type="success" @click="getList()" icon="el-icon-search">查询</el-button>
    </el-header>
    <!-- 嵌套容器 -->
    <el-container>
      <!-- 内容 -->
      <el-main>
        <!-- 第二列布局 -->
        <el-row>
          <el-col :span="30" class="col3">
            <el-table :data="tableData" stripe style="width: 100%">
              <el-table-column fixed type="index" label="序号" width="340px"></el-table-column>
              <el-table-column prop="odate" label="交易日期" sortable width="340px"></el-table-column>
              <el-table-column prop="sumprice" label="用户余额" sortable width="340px"></el-table-column>
              <el-table-column prop="identity" label="身份证" sortable width="340px"></el-table-column>
            </el-table>
          </el-col>
        </el-row>
      </el-main>
    </el-container>
    <!-- 底栏 -->
    <el-footer height="300px">
      <br />
      <br />
      <br />
      <br />
      <br />
      <br />
      <br />
      <br />
      <br />
      <br />
      <br />
      <br />
      <br />
      <br />
      <br />
      <br />
      <br />
      <br />
      <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageNo"
      :page-sizes="[1, 2, 3, 4]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
    </el-footer>
  </el-container>
</template>

<script>
import axios from "axios";
export default {
  methods: {
    ss(val) {
      if (val.state == 1) {
        return "支出";
      } else if (val.state == 2) {
        return "收入";
      }
      return;
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.pageSize = val;
      this.getList();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.pageNo = val;
      this.getList();
    },
    getList() {
      var $this = this;
      this.axios({
        method: "post",
        url: "http://localhost:9999/finance/tmsOrder/selectList",
        params: {
          pageNo: this.pageNo,
          pageSize: this.pageSize,
          startTime: this.startTime,
          endTime: this.endTime,
          access_token: localStorage.getItem("access_token")
        }
      }).then(function(res) {
        $this.tableData = res.data.obj.list;
        $this.total = res.data.obj.total;
      });
    }
  },
  data() {
    return {
      tableData: [],
      pageNo: 1,
      pageSize: 2,
      total: 10,
      onumber: "",
      startTime: "",
      endTime: "",
      state: "",
      stateList: [
        {
          id: "1",
          name: "支出"
        },
        {
          id: "2",
          name: "收入"
        }
      ]
    };
  },
  mounted() {
    this.getList();
  }
};
</script>
<style>
.el-pagination {
  text-align: center;
}
</style>
